

import UIKit
import IQKeyboardManager
import AppTrackingTransparency
import AdSupport
@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        self.window = UIWindow.init(frame: UIScreen.main.bounds)
        self.window?.backgroundColor = UIColor.white
        self.window?.rootViewController = XWLoadingViewController()
        self.window?.makeKeyAndVisible()
        iqKeyboard()
        XWDataStateTool.shareManger.startTimer()
        return true
    }
    func applicationDidBecomeActive(_ application: UIApplication) {
        let manager:ASIdentifierManager = ASIdentifierManager.shared()
        if #available(iOS 14, *) {
            ATTrackingManager.requestTrackingAuthorization { status in
                switch status {
                    case .authorized:
                        printLog("Authorized")
                        printLog(ASIdentifierManager.shared().advertisingIdentifier)
                    case .denied:
                        printLog("Denied")
                    case .notDetermined:
                        printLog("Not Determined")
                    case .restricted:
                        printLog("Restricted")
                    @unknown default:
                        printLog("Unknown")
                }
            }
        } else {
            if manager.isAccessibilityElement{
                printLog(manager.advertisingIdentifier.uuidString)
            }
        }
    }
    func applicationWillEnterForeground(_ application: UIApplication) {
        let loadingView = XWLodingView.init(frame: CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT))
        currentViewController().view .addSubview(loadingView)
//        loadingView.snp.makeConstraints { make in
//            make.top.equalTo(currentViewController().view)
//            make.left.equalTo(currentViewController().view)
//            make.right.equalTo(currentViewController().view)
//            make.bottom.equalTo(currentViewController().view)
//        }
    }
}
extension AppDelegate {
    private func iqKeyboard() {
        let manager = IQKeyboardManager.shared()
        manager.isEnabled = true
        manager.shouldResignOnTouchOutside = true
        manager.isEnableAutoToolbar = true
    }
}

